package cn.wolfcode.web.controller;


import cn.wolfcode.qo.JsonResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class JSONController {
    //存在{"success":true,"msg":"登录成功"}
    //不存在{"success":false,"msg":"登录失败"}
    @RequestMapping("/checkUsername")
    @ResponseBody
    public JsonResult checkUsername(String username) {
        //System.out.println(username);
        JsonResult jsonResult = new JsonResult();
        if ("蔡总".equals(username)) {
            jsonResult.setSuccess(true);
            jsonResult.setMsg("登录成功!");
        } else {
            jsonResult.setSuccess(false);
            jsonResult.setMsg("滚犊子!");
        }
        return jsonResult;
    }




/*
    @RequestMapping("/provinces")
    @ResponseBody
    //获取省份JSON数据
    public List<Province> getProvinces(){
        List<Province> provinces = Province.getAllProvince();
        return provinces;
    }

    @RequestMapping("/cities")
    @ResponseBody
    //获取城市JSON数据
    public List<City> getCities(Long pid){
        return City.getCityByProvinceId(pid);
    }
*/
}